import { Body, Controller, Get, Post, Request } from "@nestjs/common";

import { Public } from "src/auth/public.decorator";
import { CreateUserDto } from "./dto/user.dto";
import { UsersService } from "./users.service";

@Controller("user")
export class UsersController {
  constructor(private readonly usersService: UsersService) {}

  @Public()
  @Post("register")
  async register(@Body() createUserDto: CreateUserDto) {
    return this.usersService.create(createUserDto);
  }
  @Get("info")
  async getProfile(@Request() req) {
    return this.usersService.findById(req.user.userId);
  }
}
